import os
import random
from xml.etree.ElementTree import ElementTree,Element

path = os.getenv("appdata")
path += "\\Tencent\\WeSing\\User Data"
os.chdir(path)

tree = ElementTree()

#change KSongsWnsDataInfo.xml
root = tree.parse('KSongsWnsDataInfo.xml')
a = root[14]												#14th child																								
conf = a.findall('WnsConfigData')					
date = conf[11]											#11th child
if date.get('wnsValue') == '0':					
	date.set('wnsValue','1')
tree.write('KSongsWnsDataInfo.xml', encoding="utf-8",xml_declaration=True)

root = tree.parse('KSongsDataInfo.xml')
ID = root[0]
output = ID.find("Outputs")
tags = output.attrib
all_score = tags['AllScores']
i = len(all_score)
all_score = all_score.split(',')           					#string to list with ","
i = len(all_score)											
sum = 0
num = 0
for j in range(i):
	num = random.randint(90,100)
	all_score[j] = str(num)
	sum += num
all_score = ','.join(all_score) + ','

output.set('AllScores',all_score)
output.set('Score',str(sum))
output.set('ScoreRank','6')
output.set('FileSize',input('Enter FileSize:'))

tree.write('KSongsDataInfo.xml', encoding="utf-8",xml_declaration=True)
print('Complete')